﻿#ifndef MYSQL_H
#define MYSQL_H

#include <QMainWindow>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QDebug>

struct weather
{
    QString date;
    QString week;
    QString type;
    int low;
    int high;
    int aqi;
    weather():date(""),week(""),type(""),low(0),high(0),aqi(0){}
    weather(QString d1,QString w1,QString t1,int l1,int h1,int a1)
    {
        date=d1;
        week=w1;
        type=t1;
        low=l1;
        high=h1;
        aqi=a1;
    }
};

struct appInfo
{
    QString name;
    QString memory;
    QString comment;
    QString path;
    appInfo():name(""),memory(""),comment(""),path("")
    {

    };
    appInfo(QString n1,QString m1,QString c1,QString p1)
    {
        name=n1;
        memory=m1;
        comment=c1;
        path=p1;
    }
};

class mySql
{
public:
    mySql();
    bool openBase(void);
    bool isExist(QString &tableName);
    void commonFuc(QString &command);
    void closeBase(void);
    bool isRegistered(QString &account);
    bool isPassword(QString &account,QString &password);
    bool isCollected(QString &command);
    void findCityCode(QString &command,QString &code);
    void getAllWeather(QVector<weather> &vect);
    bool getAppInfo(QString &appName,appInfo &info);
    QSqlDatabase database;
};

#endif // MYSQL_H
